package com.xwj.sharding.controller;

import com.xwj.sharding.domain.User;
import com.xwj.sharding.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xwj
 * @date 2020/3/3
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping("/list")
    public Object list() {
        List<User> list = userService.list();
        return list;
    }

    @GetMapping("/add")
    public void add() {
        for (int i = 0; i < 10; i++) {
            User user = new User(i + "", "123456");
            userService.add(user);
        }

    }
}
